package com.autoMobile.servlet;

import com.autoMobile.bean.ddmUser;
import com.autoMobile.bean.userBean;
import com.autoMobile.dao.ddmUserDao;
import com.autoMobile.util.listData;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "IndexServlet", value = "/IndexServlet")
public class IndexServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ServletContext context=getServletContext();
        new listData().vehList(request,response,context);
        new listData().autoList(request,response,context);
        userBean user = new userBean("1","炸炸炸","1234","员工");
        ddmUser dqsq = new ddmUserDao().ListUserMy1(user.getUsername()).get(0);
        List<ddmUser> dqsq1 =  new ddmUserDao().ListUserMy1(user.getUsername());
        context.setAttribute("user",user);
        context.setAttribute("ddmUser",dqsq);
        context.setAttribute("ddmUserList",dqsq1);
        System.out.println("输出用户自己"+new ddmUserDao().ListUserMy1(user.getUsername()).get(0).toString());
        response.sendRedirect(request.getContextPath()+"/employee/dashboard.jsp");
    }
}
